#include "Iluminacao.h"

#include <GL/glui.h>

/*
    <illumination doublesided="tt" local="tt" >
        <ambient r="ff" g="ff" b="ff" a="ff" />
        <background r="ff" g="ff" b="ff" a="ff" />
    </illumination>
 */

Iluminacao::Iluminacao() {
	this->doublesided = 0;
	this->local = 1;
	this->setAmbiente(0.5,0.5,0.5,1.0);
	this->setBackground(0.0,0.0,0.0,1.0);
	// glEnable(GL_LIGHTING);
}

void Iluminacao::setAmbiente(float r, float g, float b, float a) {
	this->ambiente[0] = r;
	this->ambiente[1] = g;
	this->ambiente[2] = b;
	this->ambiente[3] = a;
}
void Iluminacao::setBackground(float r, float g, float b, float a) {
	this->background[0] = r;
	this->background[1] = g;
	this->background[2] = b;
	this->background[3] = a;
}
void Iluminacao::setDoublesided(int doublesided) {
	this->doublesided = doublesided;
}
void Iluminacao::setLocal(int local) {
	this->local = local;
}

float * Iluminacao::getAmbiente() {
	return this->ambiente;
}
float * Iluminacao::getBackground() {
	return this->background;
}
int Iluminacao::getDoublesided() const {
	return this->doublesided;
}

int Iluminacao::getLocal() const {
	return this->local;
}

void Iluminacao::aplica() {

	glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,doublesided);
	glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,local);
	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, this->getAmbiente());
	glClearColor(background[0],background[1],background[2],background[3]);
}